<?php
require_once 'phpmoko/lib/common.php';

require_once 'phpmoko/ui/HTML.php';
require_once 'phpmoko/ui/Widget.php';

class FormPanel extends Widget
{
	private $widget = null;
	private $script = null;

	/**
	 *
	 * @var string
	 */
	private $title = null;

	/**
	 *
	 * @var string
	 */
	private $method = "post";

	function __construct()
	{
		parent::__construct();
	}

	function setScript($script)
	{
		$this->script = $script;
	}

	function setWidget($widget)
	{
		$this->widget = $widget;
	}

	/**
	 *
	 * @return the $title
	 */
	public function getTitle()
	{
		return $this->title;
	}

	/**
	 *
	 * @param string $title
	 */
	public function setTitle($title)
	{
		$this->title = $title;
	}

	/**
	 *
	 * @param string $method
	 */
	public function setMethod($method)
	{
		$this->method = $method;
	}

	function toString()
	{
		$str = '<form ';

		$str .= ' id="' . $this->id . '"';

		$str .= ' action="' . $this->script . '" enctype="multipart/form-data" method="' . $this->method . '">';

		if ($this->title != null) {
			$str .= '<fieldset>';
			$str .= '<legend>' . $this->title . '</legend>';
		}

		$str .= Widget::toStringSafe($this->widget);

		if ($this->title != null)
			$str .= '</fieldset>';

		$str .= '</form>';

		return $str;
	}
}
?>